package com.yuelife.admin.controller;

import com.yuelife.admin.pojo.DUser;
import com.yuelife.admin.pojo.User;
import com.yuelife.admin.service.UserService;
import com.yuelife.admin.util.TreeNode;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private UserService userService;
    @RequestMapping(value = "/index.do")
    public String index(){
        return "index";
    }
    @RequestMapping(value = "/initIndexMenu.do")
    @ResponseBody
    public List<TreeNode> initIndexMenu(){
        Subject subject= SecurityUtils.getSubject();
        Session session=subject.getSession();
        User user=(User)session.getAttribute("USER_SESSION");
        List<TreeNode> treeNodes=userService.selectMenusByUid(user.getId());
        return treeNodes;
    }

    @RequestMapping(value = "/toUserManager.do")
    public String toUserManager(){
        return "user/userList";
    }
    @RequestMapping(value = "/toUserAddPage.do")
    public String toUserAddPage(){
        return "user/userAdd";
    }
    @RequestMapping(value = "/toUserRolePage.do")
    public String toUserRolePage(){
        return "user/userRole";
    }
    @RequestMapping(value = "/toPerssionManager.do")
    public String toperManager(){
        return "user/perList";
    }
    @RequestMapping(value = "/toRoleManager.do")
    public String toRoleManager(){
        return "role/roleList";
    }
    @RequestMapping(value = "/toAssignRightPage.do")
    public String toAssignRightPage(){
        return "role/assignRight";
    }
    @RequestMapping(value = "/toUserEidtPage.do")
    public String toUserEditPage(){
        return "user/userEdit";
    }
    //二手商品审核
    @RequestMapping("/toProductManager.do")
    public String toProductManager(){
        return "product/productList";
    }
    //分类管理
    @RequestMapping("/toTypeManager.do")
    public String toTypeManager(){
        return "product/typeList";
    }
    //查看商品详情
    @RequestMapping("/tolookProduct.do")
    public String tolookProduct(){
        return "product/lookProduct";
    }
    //审核通过的所有商品
    @RequestMapping("/toProduct.do")
    public String toProduct(){
        return "product/productAll";
    }
    @RequestMapping("/toEditCategory.do")
    public String toEditCategory(){
        return "product/editCategory";
    }
    @RequestMapping("/toDiscussion.do")
    public String toDiscussion(){return "discussion/discussionList";}
    @RequestMapping("/toProperty.do")
    public String toProperty(){return "property/propertyEdit";}
    @RequestMapping("/toremoveDiscussion.do")
    public String toremoveDiscussion(){return "discussion/removeDiscussion";}

}
